package easy.trace.agent.support;


import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TraceConfiguration {
    private List<String> services;
    @Value("${easy.trace.client.name:}")
    private String applicationName;
    @Value("${easy.trace.client.delayTime:3000}")
    private Long delayTime;
    @Value("${easy.trace.client.flushSize:10}")
    private Long flushSize;
    @Value("${easy.trace.client.queueSize:1024}")
    private Integer queueSize;
    @Value("${spring.application.name:}")
    private String appName;
    @Value("${dubbo.application.name:}")
    private String dubboName;

    public TraceConfiguration() {
    }

    public String getApplicationName() {
        if (!this.applicationName.isEmpty()) {
            return this.applicationName;
        } else if (!this.appName.isEmpty()) {
            return this.appName;
        } else {
            return !this.dubboName.isEmpty() ? this.dubboName : "UNKOWN";
        }
    }

    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }

    public List<String> getServices() {
        return this.services;
    }

    public void addService(String service) {
        if (this.services == null) {
            this.services = new ArrayList();
        }

        this.services.add(service);
    }

    public void setServices(List<String> services) {
        this.services = services;
    }

    public Long getDelayTime() {
        return this.delayTime;
    }

    public void setDelayTime(Long delayTime) {
        this.delayTime = delayTime;
    }

    public Long getFlushSize() {
        return this.flushSize;
    }

    public void setFlushSize(Long flushSize) {
        this.flushSize = flushSize;
    }

    public Integer getQueueSize() {
        return this.queueSize;
    }

    public void setQueueSize(Integer queueSize) {
        this.queueSize = queueSize;
    }
}

